package io.xccit.race.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.xccit.common.annotation.Log;
import io.xccit.common.core.controller.BaseController;
import io.xccit.common.core.domain.AjaxResult;
import io.xccit.common.enums.BusinessType;
import io.xccit.race.domain.RaceCompetitionWin;
import io.xccit.race.service.IRaceCompetitionWinService;
import io.xccit.common.utils.poi.ExcelUtil;
import io.xccit.common.core.page.TableDataInfo;

/**
 * 竞赛获奖管理Controller
 * 
 * @author ywx
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/race/win")
public class RaceCompetitionWinController extends BaseController {
    @Autowired
    private IRaceCompetitionWinService raceCompetitionWinService;

    /**
     * 查询竞赛获奖管理列表
     */
    @PreAuthorize("@ss.hasPermi('race:win:list')")
    @GetMapping("/list")
    public TableDataInfo list(RaceCompetitionWin raceCompetitionWin) {
        startPage();
        List<RaceCompetitionWin> list = raceCompetitionWinService.selectRaceCompetitionWinList(raceCompetitionWin);
        return getDataTable(list);
    }

    /**
     * 导出竞赛获奖管理列表
     */
    @PreAuthorize("@ss.hasPermi('race:win:export')")
    @Log(title = "竞赛获奖管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RaceCompetitionWin raceCompetitionWin) {
        List<RaceCompetitionWin> list = raceCompetitionWinService.selectRaceCompetitionWinList(raceCompetitionWin);
        ExcelUtil<RaceCompetitionWin> util = new ExcelUtil<RaceCompetitionWin>(RaceCompetitionWin.class);
        util.exportExcel(response, list, "竞赛获奖管理数据");
    }

    /**
     * 获取竞赛获奖管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('race:win:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(raceCompetitionWinService.selectRaceCompetitionWinById(id));
    }

    /**
     * 新增竞赛获奖管理
     */
    @PreAuthorize("@ss.hasPermi('race:win:add')")
    @Log(title = "竞赛获奖管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RaceCompetitionWin raceCompetitionWin) {
        return toAjax(raceCompetitionWinService.insertRaceCompetitionWin(raceCompetitionWin));
    }

    /**
     * 修改竞赛获奖管理
     */
    @PreAuthorize("@ss.hasPermi('race:win:edit')")
    @Log(title = "竞赛获奖管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RaceCompetitionWin raceCompetitionWin) {
        return toAjax(raceCompetitionWinService.updateRaceCompetitionWin(raceCompetitionWin));
    }

    /**
     * 删除竞赛获奖管理
     */
    @PreAuthorize("@ss.hasPermi('race:win:remove')")
    @Log(title = "竞赛获奖管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(raceCompetitionWinService.deleteRaceCompetitionWinByIds(ids));
    }
}
